<?php

class Default_MediaController extends Zend_Controller_Action
{

    public $MediaIndex = null;

    public function init()
    {
        Zend_Session::start();
        $Session = new Zend_Session_Namespace ('Params'); 
        $this->view->Persisted = $Session->Persisted; 
        $this->MediaIndex = new Default_Model_MediaIndex; 
    }

    public function indexAction()
    {
        $this->MediaIndex->LoadGroups(true);
        $this->view->groups  = $this->MediaIndex->Groups;  

         # ('alt.binaries.multimedia.erotica.teen', 1);  
         # var_dump($this->MediaIndex->Files);

    }

    public function listAction()
    {
        $request    = $this->getRequest(); 
        $groupname  = $request->getParam('group'); 
        $pagenumber = $request->getParam('page'); 
        if (!isset($pagenumber)) $pagenumber=1;
        $this->MediaIndex->GetFiles ($groupname, 1); 
 
        $this->view->groups = $this->MediaIndex->Groups;
        $this->view->files  = $this->MediaIndex->Files;
        $this->view->group  = $groupname;
        $this->view->page   = $pagenumber;
 
        $startIndex  = ($pagenumber - 1) * 10; 
        $this->view->sets    = array_slice ($this->view->files, $startIndex, 10);
 
    }

    public function viewAction()
    {
        $this->_helper->layout->setLayout('blank');
        $request = $this->getRequest(); 
        $groupname  = $request->getParam('group'); 
        $id         = $request->getParam('id'); 

        $this->MediaIndex->GetArticle($groupname, $id);

        $this->view->article = $this->MediaIndex->Article;
        $this->view->group   = $groupname;
        $this->view->files   = $this->MediaIndex->Files;  

    }

}










